﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;

namespace EDMS
{
    public partial class AddSelection : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        //确定添加
        protected void btnOK_Click(object sender, EventArgs e)
        {
            if (txtXjbh.Text.Equals(""))
            {
                Frame.Global.GlobalFunctions.Alert("请添加选举编号！");
            }
            else if (txtXjmc.Text.Equals(""))
            {
                Frame.Global.GlobalFunctions.Alert("请输入选举名称！");
            }
            else if (deXjsj.Text.Equals(""))
            {
                Frame.Global.GlobalFunctions.Alert("请输入选举时间！");
            }
            else if (deWtjssj.Text.Equals(""))
            {
                Frame.Global.GlobalFunctions.Alert("请输入委托结束时间！");
            }
            
            else
            {
                insertSelection();
            }
        }
        //添加选举信息
        private void insertSelection()
        {
            using (DataClassesDataContext dc = new DataClassesDataContext())
            {
                Xjdj xj = new Xjdj();
                xj.xjbh = txtXjbh.Text.Trim().ToString();
                xj.xjmc = txtXjmc.Text.Trim().ToString();
                xj.xjsj = Convert.ToDateTime(deXjsj.Text);
                xj.wtjssj = Convert.ToDateTime(deWtjssj.Text);
                xj.flag = "A";
                dc.Xjdj.InsertOnSubmit(xj);
                dc.SubmitChanges();
                Frame.Global.GlobalFunctions.Alert("选举信息添加成功");
            }
        }
        //信息重置
        protected void btnEsc_Click(object sender, EventArgs e)
        {
            txtXjbh.Text = "";
            txtXjmc.Text = "";
            deXjsj.Text = "";
            deWtjssj.Text = "";
            //cmbHdbj.Text = "";
        }
    }
}